Page({
  data: {
    list: [],
  },
  onLoad({ id }) {
    // console.log('信息', options.id);
    this.getList(id)
  },
  async getList(id) {
    const res = await wx.http.get('/visitor/' + id)
    // console.log('列表', res);
    this.setData({
      list: res.data
    })
    // console.log(this.data.list);
  },
  onShareAppMessage() {
    //自定义分享的内容
    return {
      title: '查看通行证',
      path: `/visitor_pkg/pages/passport/index?id=${this.id}`,
      imageUrl: this.data.url || 'https://enjoy-plus.oss-cn-beijing.aliyuncs.com/images/share_poster.png',
    }
  },
  //保存访客二维码图片路径到本地
  async saveImg() {
    //1.把网络地址转化为本地保存地址
    const res = await wx.getImageInfo({ src: this.data.list.url })
    // console.log('保存路径', res.path);
    //2.保存到本地
    await wx.saveImageToPhotosAlbum({ filePath: res.path })
    //3.提示保存成功
    wx.utils.message('保存成功！')
  }
})
